package com.tarry.observer.jdk;


import java.util.Observable;
import java.util.Observer;

/**
 * 观察者
 */
public class Subscriber implements Observer {

    /**
     * 向发布者注册自己
     * @param observable
     */
    public Subscriber(Observable observable){
        observable.addObserver(this);
    }

    @Override
    public void update(Observable o, Object arg) {
        System.out.println("收到通知:" + ((Publisher) o).getMsg());
    }
}
